package com.wang.back.controller;

import com.wang.controller.BaseController;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;

/**
 * 这个是不需要登录的请求;
 * 
 * <pre>
 * 这里面存储的是登录后的页面
 * </pre>
 * @author Zjx
 */
@Controller
@RequestMapping(value = "/back/AdminsBack")
@Log4j2
public class AdminsBackController extends BaseController {

	/**
	 * 退出
	 * @param request
	 * @param response
	 * @throws IOException 
	 * @throws ServletException
	 */
	@RequestMapping("/logout")
	public String logout(HttpServletRequest request, HttpServletResponse response){
		/* 登录的时候怎么做,退出的时候就怎么做 */
		HttpSession session = request.getSession();
		/* 删除 */
		session.removeAttribute("adminsSess");
		session.removeAttribute("lastLoginTime");
		String info = "退出成功";
		session.setAttribute("info", info);
		/* 跳转到登录页面 */
		return "redirect:/NoLogin/adminsLogin";
	}

	/**
	 * 欢迎页面
	 */
	@RequestMapping("/welcome")
	public String welcome(){
		log.info("==welcome==");
		return "/back/admins/welcome";
	}

	/**
	 * 打开登录页面
	 */
	@RequestMapping("/main")
	public String main(){
		log.info("==main==");
		return "/back/admins/main";
	}
}
